package mapmaker.robot.engine;
import net.sf.json.JSONObject;


public class DifferentialDrive {
		private DifferentialDriveCommand _command;
		private DifferentialDriveFeedback _feedback;
		private DifferentialDriveProperties _properties;
		private long _timestamp;
		
		public DifferentialDrive(DifferentialDriveCommand command,
				DifferentialDriveFeedback feedback,
				DifferentialDriveProperties properties, long timestamp) {
			_command = command;
			_feedback = feedback;
			_properties = properties;
			_timestamp = timestamp;
		}

		public DifferentialDriveCommand getCommand() {
			return _command;
		}

		public void setCommand(DifferentialDriveCommand command) {
			_command = command;
		}

		public DifferentialDriveFeedback getFeedBack() {
			return _feedback;
		}

		public void setFeedBack(DifferentialDriveFeedback feedback) {
			_feedback = feedback;
		}

		public DifferentialDriveProperties getProperties() {
			return _properties;
		}

		public void setProperties(DifferentialDriveProperties properties) {
			_properties = properties;
		}

		public long getTimestamp() {
			return _timestamp;
		}

		public void setTimestamp(long timestamp) {
			this._timestamp = timestamp;
		}
		
		/**
		 * Set differential drive from JSONObject
		 * @param obj the object containing values we want to store in differential drive objet
		 */
		public void setDifferentialDriveFromJSONObject(JSONObject obj){
			_command.setTargetAngularSpeed(obj.getJSONObject("Command").getDouble("TargetAngularSpeed")); 
			_command.setTargetLinearSpeed(obj.getJSONObject("Command").getDouble("TargetLinearSpeed"));
			_feedback.setCurrentAngularSpeed(obj.getJSONObject("Feedback").getDouble("CurrentAngularSpeed"));
			_feedback.setCurrentLinearSpeed(obj.getJSONObject("Feedback").getDouble("CurrentLinearSpeed"));
			_feedback.setEnabled(obj.getJSONObject("Feedback").getBoolean("Enabled"));
			_properties.setMaxAngularAcceleration(obj.getJSONObject("Properties").getInt("MaxAngularAcceleration"));
			_properties.setMaxAngularSpeed(obj.getJSONObject("Properties").getInt("MaxAngularSpeed"));
			_properties.setMinAngularSpeed(obj.getJSONObject("Properties").getInt("MinAngularSpeed"));
			_properties.setMaxAngularDeceleration(obj.getJSONObject("Properties").getInt("MaxAngularDeceleration"));
			_properties.setMaxLinearAcceleration(obj.getJSONObject("Properties").getInt("MaxLinearAcceleration"));
			_properties.setMaxLinearDeceleration(obj.getJSONObject("Properties").getInt("MaxLinearDeceleration"));
			_properties.setMaxLinearSpeed(obj.getJSONObject("Properties").getInt("MaxLinearSpeed"));
			_properties.setMinLinearSpeed(obj.getJSONObject("Properties").getInt("MinLinearSpeed"));
			_properties.setWidth(obj.getJSONObject("Properties").getInt("Width"));
		
		}
		
		
}
